﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;





public enum SoulType
{
    Mage,
    Hunter,
    Warrior,
}


public interface ISoul
{
    void CastSkill();
}

public class Mage : ISoul
{
    public void CastSkill()
    {
        Debug.Log("Summon a box");
    }
}

public class Hunter : ISoul
{
    public void CastSkill()
    {
        Debug.Log("Fire arrow");
    }
}

public class Warrior : ISoul
{
    public void CastSkill()
    {
        Debug.Log("Power of Thor");
    }
}



public class Hero
{
    private Mage _mage = new Mage();
    private Hunter _hunter = new Hunter();
    private Warrior _warrior = new Warrior();
    private SoulType _soulType = SoulType.Mage;
    public void CastSkill()
    {
        ISoul activeSoul = null;
        switch (_soulType)
        {
            case SoulType.Mage:
                activeSoul = _mage;
                break;
            case SoulType.Hunter:
                activeSoul = _hunter;
                break;
            case SoulType.Warrior:
                activeSoul = _warrior;
                break;
        }
        activeSoul.CastSkill();
    }
    public void ChangeSoul(SoulType soulType)
    {
        _soulType = soulType;
    }
}


public class Priest : ISoul
{
    public void CastSkill()
    {
        Debug.Log("Mind control");
    }
}

public class TrineHero
{
    private ISoul _soul;
    public void CastSkill()
    {
        _soul.CastSkill();
    }

    public void ChangeSoul<T>() where T : ISoul, new()
    {
        _soul = new T();
    }
}


public class Bridge : MonoBehaviour
{

    void Start()
    {
        //Hero hero = new Hero();
        //hero.ChangeSoul(SoulType.Hunter);
        //hero.CastSkill();
        TrineHero th = new TrineHero();
        th.ChangeSoul<Priest>();
        th.CastSkill();
    }


}
